
#include "smg.h"
#include "key.h"
#include "can.h"
#include "delay.h"
#include "datesheet.h"
#include "errormodel.h"
void ErrorModel(void)
{
	u8 i = 0;
	u8 led_coulour = LEDOFF;
	ErrorStep = 0;
	DisplayFlg = 1;
	SMGStatus = 0;
	SMGUpdataFlg = 1;
	LEDStatus = 0;
	LEDUpdataFlg = 1;
	LedCoulour = LEDOFF;
	DisplayDateClear();
	while(1)
	{
		if(ErrorDisplayFlg == 0)
		{
			LedCoulour = GREEN;
			break ;
		}
		if(KeyValue == STOP_KEY_PRESS)
		{
			KeyValue = NO_KEY_PRESS;
			CAN_SetMsgOneByte(POWER_OFF,0XFF);
		}
		if(KeyValue == STOP_KEY_LONG_PRESS)
		{
			KeyValue = NO_KEY_PRESS;
			CAN_SetMsgOneByte(Error_ID,0XFF);
		}
		
		if(LEDStatus)
		{
			LedCoulour = RED;
		}
		else 
		{
			LedCoulour = led_coulour;
		}
		switch(ErrorStep)
		{
			case 0:
				if(ErrorArray[1][i] == 1)
				{
					ErrorNum = ErrorArray[0][i];
					ErrorStep = 1;
					SMGStatus = 0;
					
					if(i == 4||i == 5)
					{
						led_coulour = BLUE;
					}
					else if(i == 9 ||i == 10 ||i == 11||i == 12||i == 18||i == 19||i == 20)
					{
						led_coulour = RED;
					}
					else 
					{
						led_coulour = LEDOFF;
					}
				}
				else 
				{
					i++;
				}
				

			break ;
			
			case 1:
				

				if(SMGStatus)
				{
					i++;
					ErrorStep = 0;
				}
			break ;
			
			default: break ;
																		
		}
		if(i > 27) i = 0;

		ThreeCharDisplay(E,r,r);
		PressDispaly(ErrorNum,0,0);
	}
	for(i = 0;i<27;i++)
	{
		ErrorArray[1][i] = 0;
	}
	DisplayFlg = 0;
	LedCoulour = LEDOFF;
}
